package com.myjianzhu.zzt88.exercise.android.activities;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.ViewStub;

import com.myjianzhu.zzt88.exercise.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MergeViewStubActivity extends AppCompatActivity {

    @BindView(R.id.view_stub)
    ViewStub viewStub;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_merge_viewstub);
        ButterKnife.bind(this);
    }

    boolean hasInflate = false;

    @OnClick(R.id.show)
    void showStub() {
        if (!hasInflate) {
            viewStub.inflate();
            hasInflate = true;
        }
    }

    public static void start(Activity activity) {
        Intent intent = new Intent(activity, MergeViewStubActivity.class);
        ActivityCompat.startActivity(activity, intent, null);
    }
}
